<?php
	require_once("../../library/function/connect.php");
	require_once("../../library/function/MasterTool.php");
	$obj = new MasterTool();
	
	$name = mysql_real_escape_string(strip_tags($_POST['name']));
	$alias = $obj->str_alias($obj->vn_str_filter($name));
	
	$row = mysql_fetch_array(mysql_query(" SELECT max(position) ps FROM nhom "));
	$position = $row['ps'] == "" ? 0 : $row['ps']+1;
	$create_date = $obj->CurrentDate() . " " . $obj->CurrentTime();
	
	$query = mysql_query(" INSERT INTO nhom(name, alias, position, create_date)
							VALUES(N'$name', '$alias', '$position', '$create_date') ");
	
	if($query)
		echo "0";
	else	
		echo "1";
?>